package com.example.mountainwalker.mapper;

import com.example.mountainwalker.entity.TravelAgencyAuditDetail;
import com.example.mountainwalker.entity.TravelAgencyImageInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface TravelAgencyAuditMapper {
    @Select("SELECT " +
            "ta.travel_agency_id as travelAgencyId, " +
            "ta.travel_agency_name as travelAgencyName, " +
            "ta.travel_agency_avatar as travelAgencyAvatar, " +
            "ta.travel_agency_introduction as travelAgencyIntroduction, " +
            "r.province, r.city, " +
            "ta.office_address as officeAddress, " +
            "ta.office_phone as officePhone, " +
            "ta.office_email as officeEmail, " +
            "ta.principal_name as principalName, " +
            "ta.principal_phone as principalPhone, " +
            "ta.registration_time as registrationTime, " +
            "ta.audit_status as auditStatus " +
            "FROM travel_agency ta " +
            "LEFT JOIN region r ON ta.region_id = r.region_id " +
            "WHERE ta.travel_agency_id = #{id}")
    TravelAgencyAuditDetail getTravelAgencyDetailById(@Param("id") Integer id);


    @Select("SELECT " +
            "agency_image_id as agencyImageId, " +
            "scenic_spot_image as scenicSpotImage " +
            "FROM travel_agency_image " +
            "WHERE travel_agency_id = #{travelAgencyId}")
    List<TravelAgencyImageInfo> getAgencyImages(@Param("travelAgencyId") Integer travelAgencyId);

    @Update("UPDATE travel_agency SET " +
            "audit_status = #{status} " +
            "WHERE travel_agency_id = #{id}")
    int updateAuditStatus(@Param("id") Integer id, @Param("status") String status);
}